package it.orma.iridehr.controllers;

import it.orma.iridehr.exceptions.DatiException;
import it.orma.iridehr.service.TipologicheService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

@Controller
public class TipologieProgrammiController {

	@Autowired
	private TipologicheService tipologicheService;

	@RequestMapping(value ="/grafica.json", method = RequestMethod.GET, produces = "application/json")
	public @ResponseBody List<String> grafica(){

		try {
			return tipologicheService.listaProgrammi("grafica");
		} catch (DatiException e) {
			return new ArrayList<String>();
		}
	}

	@RequestMapping(value ="/applicazioni.json", method = RequestMethod.GET, produces = "application/json")
	public @ResponseBody List<String> applicazioni(){
		try {
			return tipologicheService.listaProgrammi("gestionali");
		} catch (DatiException e) {
			return new ArrayList<String>();
		}
	}

	@RequestMapping(value ="/linguaggi.json", method = RequestMethod.GET, produces = "application/json")
	public @ResponseBody List<String> linguaggi(){
		try {
			return tipologicheService.listaProgrammi("linguaggi");
		} catch (DatiException e) {
			return new ArrayList<String>();
		}
	}
}
